// https://leetcode.cn/problems/populating-next-right-pointers-in-each-node/
// 利用已建立的next指针
class Solution {
public:
    Node* connect(Node* root) {
        if (!root) return NULL;
        if (root->left) {
            root->left->next = root->right;
            if (root->next) root->right->next = root->next->left;
        }
        connect(root->left);
        connect(root->right);
        return root;
    }
};